﻿using DependencyAnalysis.DataModel;
using Xunit;

namespace XUnitExample
{
    public class GenericContext
    {       
    }

    public class AssemblyReferenceTest : DependencyTest, IUseFixture<GenericContext>
    {
        public void SetFixture(GenericContext data)
        {
            _dependencyAnalysis = DescriptorBuilder.BuildModuleDescriptor(typeof(DependencyAnalysis.Properties.IAssemblyIdentifier).Assembly);
            _addin = DescriptorBuilder.BuildModuleDescriptor(typeof(theeg.DependencyAnalysis.CommonAddin.Properties.IAssemblyIdentifier).Assembly);
            _sdAddin = DescriptorBuilder.BuildModuleDescriptor(typeof(theeg.DependencyAnalysis.SdAddin.IAssemblyIdentifier).Assembly);
            _vsAddin = DescriptorBuilder.BuildModuleDescriptor(typeof(theeg.DependencyAnalysis.VsAddin2012.IAssemblyIdentifier).Assembly);
            _analysisHost = DescriptorBuilder.BuildModuleDescriptor(typeof(AnalysisHost.Properties.IAssemblyIdentifier).Assembly);
        }

        private ModuleDescriptor _dependencyAnalysis;
        private ModuleDescriptor _addin;
        private ModuleDescriptor _analysisHost;
        private ModuleDescriptor _sdAddin;
        private ModuleDescriptor _vsAddin;

        [Fact]
        public void LimitForeignModules()
        {
            Verifier.VerifyForeignModules(new[] { "theeg.GraphWpf", "ICSharpCode.Core", "ICSharpCode.SharpDevelop" });
        }

        [Fact]
        public void AnalysisHostEfferences()
        {
            Verifier.VerifyDoesNotReferTo(_analysisHost, _addin);
            Verifier.VerifyDoesNotReferTo(_analysisHost, _sdAddin);
            Verifier.VerifyDoesNotReferTo(_analysisHost, _vsAddin);
        }

        [Fact]
        public void DependencyAnalysisEfferences()
        {
            Verifier.VerifyDoesNotReferTo(_dependencyAnalysis, _addin);
            Verifier.VerifyDoesNotReferTo(_dependencyAnalysis, _analysisHost);
            Verifier.VerifyDoesNotReferTo(_dependencyAnalysis, _sdAddin);
            Verifier.VerifyDoesNotReferTo(_dependencyAnalysis, _vsAddin);
        }

        [Fact]
        public void VsAddinEfferences()
        {
            Assert.True(Verifier.RefersTo(_vsAddin, _addin));
        }

        [Fact]
        public void SdAddinEfferences()
        {
            Assert.True(Verifier.RefersTo(_sdAddin, _addin));
        }
    }
}
